import QtQuick 2.0
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.12

Item {
    width: 850
    height: 580

    Rectangle
    {
        id:p4n_toobarHeader
        height: 40
        width:parent.width
        radius: height/2
        color: "#883080a0"

        Label {
            id:label_date
            color: "#40ffff"
            text: qsTr("日期")
            anchors.left: parent.left
            anchors.right: ats.left
            font.bold: true
            font.family: "Tahoma"
            font.pixelSize: 17*main_screen.minSize
            anchors.verticalCenter: parent.verticalCenter
            elide: Label.ElideRight
            horizontalAlignment: Qt.AlignHCenter
            verticalAlignment: Qt.AlignVCenter
        }
        ToolSeparator {
            id:ats
            x:parent.width*0.20
            height: parent.height
            MouseArea{
                height: parent.height
                anchors.leftMargin: -width/2+parent.width/2
                width: 50
                anchors.left: parent.left
                acceptedButtons: Qt.LeftButton //只处理鼠标左键
                onPositionChanged: {
                    parent.x = mouseX+parent.x-width/2
                }
            }
        }
        Label {
            id:label_time
            color: "#40ffff"
            text: qsTr("时间")
            anchors.left: ats.right
            anchors.right: bts.left
            font.bold: true
            font.family: "Tahoma"
            font.pixelSize: 17*main_screen.minSize
            anchors.verticalCenter: parent.verticalCenter
            elide: Label.ElideRight
            horizontalAlignment: Qt.AlignHCenter
            verticalAlignment: Qt.AlignVCenter
        }
        ToolSeparator {
            id:bts
            x:parent.width*0.40
            height: parent.height
            MouseArea{
                height: parent.height
                anchors.leftMargin: -width/2+parent.width/2
                width: 50
                anchors.left: parent.left
                acceptedButtons: Qt.LeftButton //只处理鼠标左键
                onPositionChanged: {
                    parent.x = mouseX+parent.x-width/2
                }
            }
        }
        Label {
            id:label_text
            color: "#40ffff"
            text: qsTr("报警文本")
            anchors.left: bts.right
            anchors.right: parent.right
            font.bold: true
            font.family: "Tahoma"
            font.pixelSize: 17*main_screen.minSize
            anchors.verticalCenter: parent.verticalCenter
            elide: Label.ElideRight
            horizontalAlignment: Qt.AlignHCenter
            verticalAlignment: Qt.AlignVCenter
        }

    }
    Rectangle
    {
        id:p4n_toobarBotton
        height: 40
        width: parent.width
        anchors.bottom: parent.bottom
        radius: height/3
        color: "#883080a0"
        Label {
            text: qsTr("提示")
            font.bold: true
            font.family: "Tahoma"
            font.pointSize: 16
            color: "#40ffff"
            anchors.verticalCenter: parent.verticalCenter
            width: parent.width
            elide: Label.ElideRight
            horizontalAlignment: Qt.AlignHCenter
            verticalAlignment: Qt.AlignVCenter
        }
    }

    ListView {
        id: p4n_listView
        clip: true
        width: parent.width
        anchors.top: p4n_toobarHeader.bottom
        snapMode: ListView.SnapToItem
        orientation:ListView.Vertical
        anchors.bottom: p4n_toobarBotton.top

        ScrollBar.vertical: ScrollBar {
            width: 25
            active: true
            anchors.right: parent.right
            parent: parent
        }

        model:ListModel{
            id:p4n_listView_model
        }

        delegate:Item {
            id: wrapper
//            property color textColor: "#40FFFF"
            width: parent.width
            height: 30

            EXC_listViewItemDelegate3{
                id: p4n_listViewItemdeleg_data
                height: 30
                locationBase: label_date
                mcolor: "#40ffff"
                mtext: text_date
                textFontpixelSize: 21*main_screen.minSize
            }

            EXC_listViewItemDelegate3{
                id: p4n_listViewItemdeleg_time
                height: 30
                locationBase: label_time
                mcolor: "#40ffff"
                mtext: text_time
                textFontpixelSize: 21*main_screen.minSize
            }
            EXC_listViewItemDelegate3{
                id: p4n_listViewItemdeleg_text
                height: 30
                locationBase: label_text
                mcolor: "#40ffff"
                mtext: text_represent
                textFontpixelSize: 21*main_screen.minSize
            }

        }
    }

    function addModel(data, time, represent)
    {
        p4n_listView_model.insert(0,
                                  {
                                      "textColor":"#ffffff",
                                      "text_date":data,
                                      "text_time":time,
                                      "text_represent":represent
                                  })
    }
    function addModelRed(data, time, represent)
    {
        p4n_listView_model.insert(0,
                                  {
                                      "textColor":"#dc4e4e",
                                      "text_date":data,
                                      "text_time":time,
                                      "text_represent":represent
                                  })
    }
    function addModelWithColor(color,data, time, represent)
    {
        p4n_listView_model.insert(0,
                                  {
                                      "textColor":color,
                                      "text_date":data,
                                      "text_time":time,
                                      "text_represent":represent
                                  })
    }
    function removeModel(which)
    {
        p4n_listView_model.remove(which)
    }
    function clearModel()
    {
        p4n_listView_model.clear()
    }
}

/*##^##
Designer {
    D{i:0;formeditorZoom:0.75}
}
##^##*/
